<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<!--引入css-->
<head >
    <title th:text="系统权限表表单">欢迎页</title>
    <link th:replace="admin/include/head :: head">
    <link rel="stylesheet" th:href="@{/resources/awi/plugins/z-tree3.5/css/metro/zTreeStyle.css}">
</head>
<body>

<div class="col-md-12 box">
    <form id="form" class="form-horizontal">
        <input type="hidden" id="id" name="id">
        <div class="box-body">
            <div class="form-group">
                <label for="name" class="col-sm-2 control-label">权限名称</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="name" name="name" autocomplete="off">
                </div>
            </div>
            <div class="form-group">
                <label for="parentId" class="col-sm-2 control-label">上级权限</label>
                <div class="col-sm-10">
                    <input type="hidden" class="form-control" id="parentId"   name="parentId" >
                    <input type="text" class="form-control" id="parentName"   name="parentName" onclick="openPermissionTree()" readonly="readonly" style="background-color: white;">
                </div>
            </div>
            <div class="form-group">
                <label for="permission" class="col-sm-2 control-label">权限标识</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="permission"   name="permission" autocomplete="off">
                </div>
            </div>
            <div class="form-group">
                <label for="sort" class="col-sm-2 control-label">权限排序</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="sort" name="sort" value="1">
                </div>
            </div>
        </div>
        <div class="box-footer">
            <button type="button" class="btn btn-info pull-right" onclick="beforeSavepop()">提交</button>
        </div>
    </form>
</div>

<!--引入js-->
<div th:replace="admin/include/footer :: foot"></div>
<script th:src="@{/resources/common/crud.js}"></script>
<script th:src="@{/resources/awi/plugins/z-tree3.5/js/jquery.ztree.all-3.5.js}"></script>
</body>

<div id="zTree" style="display: none;" class="box">
    <div style="padding: 10px; height:90%;" class="box">
        <ul id="typeTree" class="ztree"></ul>
    </div>
</div>

<script th:inline="javascript">
    var index = parent.layer.getFrameIndex(window.name);
    var id=[[${id!=null?id:''}]];
    $(function () {
        initTree('/admin/sysPermission/zTreeNodes', 'typeTree', 0, "parentName", "parentId");
        popInit('/admin/sysPermission/get', "form", id);
    });

    function openPermissionTree() {
        openTree("zTree");
    }

    function beforeSavepop(){
        if (!$("#name").val()) { layer.msg("权限名称不能为空！"); return false; }
        if (!$("#permission").val()) { layer.msg("权限标识不能为空！"); return false; }
        if (!$("#sort").val()) { layer.msg("权限排序不能为空！"); return false; }
        savepop('/admin/sysPermission/save', 'form');
    }
</script>
</html>